﻿<!DOCTYPE html>
<html ng-app="demoApp" lang="en">
<head>
    <title id='Description'>In this example the Angular ComboBox is bound to a Remote Data.</title>
    <meta name="description" content="AngularJS ComboBox example. This example demonstrates a ComboBox data bound to remote data source using JSONP." /> 
    <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../../scripts/angular.min.js"></script>
     <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> 
    <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxcombobox.js"></script>
    <script type="text/javascript" src="../../../scripts/demos.js"></script>
    <script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script>
    <script type="text/javascript">
        var demoApp = angular.module("demoApp", ["jqwidgets"]);
        demoApp.controller("demoController", function ($scope) {
            // prepare the data
            var source =
            {
                datatype: "jsonp",
                datafields: [
                    { name: 'countryName' },
                    { name: 'name' },
                    { name: 'population', type: 'float' },
                    { name: 'continentCode' }
                ],
                url: "http://api.geonames.org/searchJSON",
                data: {
                    featureClass: "P",
                    style: "full",
                    maxRows: 50,
                    username: "jqwidgets"
                }
            };

            var dataAdapter = new $.jqx.dataAdapter(source);

            $scope.comboBoxSettings =
            {
                width: 200,
                height: 25,
                source: dataAdapter,
                selectedIndex: 0,
                displayMember: "countryName",
                valueMember: "name"
            };

            // trigger the select event.
            $scope.selectHandler = function (event) {
                if (event.args) {
                    var item = event.args.item;
                    if (item) {
                        $scope.log = "Label: " + item.label + ", Value: " + item.value;
                    }
                }
            };
        });
    </script>
</head>
<body ng-controller="demoController">
    <jqx-combo-box jqx-settings="comboBoxSettings" jqx-on-select="selectHandler(event)"></jqx-combo-box>
    <br />
    {{log}}
</body>
</html>
